<?php
/**
 * Created by JetBrains PhpStorm.
 * User: kimphuc
 * Date: 6/29/12
 * Time: 2:52 PM
 * To change this template use File | Settings | File Templates.
 */
class CNewsActiveRecord extends CActiveRecord
{
    public static $news_db = null;

    public function getDbConnection()
    {
        if (self::$news_db !== null) {
            return self::$news_db;
        } else {
            self::$news_db = Yii::app()->news_db;

            if (self::$news_db instanceof CDbConnection) {
                self::$news_db->setActive(true);
                return self::$news_db;
            } else {
                throw new CDbException(Yii::t('yii','Active Record requires a "db" CDbConnection application component.'));
            }
        }
    }
}
